#[derive(Debug)]
enum PersonId {
    // 括号里是和携带的数据的类型
    Passport(String),
    UUID(String),
    IndentityCard(u32, u32, u32),
}

struct Person {
    name: String,
    last_name: String,
    age: u32,
    id: PersonId,
}

impl Person {
    // associated function
    // 这种方法适用于构造方法
    fn new() -> Person {
        Person {
            name: "default".to_string(),
            last_name: "default".to_string(),
            age: 0,
            id: PersonId::UUID("865fbd57-64b6-4064-8207-2368ead0436e".to_string()),
        }
    }

    fn from(name: String, last_name: String, age: u32, id: PersonId) -> Person {
        Person {
            name,
            last_name,
            age,
            id,
        }
    } 

    fn change_age(&mut self, new_age: u32) {
        self.age = new_age;
    }
}
fn main() {
    let mut p = Person::new();
    p.change_age(12);
    // `PersonId` cannot be formatted with the default formatter
    println!("{} {} {} {:?}", p.name, p.last_name, p.age, p.id);

    let p1 = Person::from(
        "name".to_string(),
        "last_name".to_string(),
        18,
        PersonId::IndentityCard(1, 00, 86),
    );
    println!("{} {} {} {:?}", p1.name, p1.last_name, p1.age, p1.id);
}
